<template>
  <div class="soft-bg">
    <el-container class="soft-container">
      <el-main>
        <MainMenu v-if="page==='menu'"
          @showHome="page='home'"
          @showConfig="page='config'"
          @showHelp="page='help'"
          @showMainProcess="page='mainprocess'"
          @showRoomManager="page='roommanager'"
        />
        <div v-if="page==='home'" class="center-panel-card no-margin-card">
          <HomeGrid 
            @showQr="page='qr'" 
            @showAiChat="page='aichat'" 
            @showDanmu="page='danmu'" 
            @showMainProcess="page='mainprocess'" 
            @showRoomManager="page='roommanager'" />
          <el-button class="back-btn" @click="page='menu'" type="info" plain>返回首页</el-button>
        </div>
        <div v-if="page==='mainprocess'" class="center-panel-card no-margin-card">
          <MainProcessPanel />
          <el-button class="back-btn" @click="page='menu'" type="info" plain>返回首页</el-button>
        </div>
        <div v-if="page==='danmu'" class="center-panel-card no-margin-card">
          <DanmuPanel />
          <el-button class="back-btn" @click="page='home'" type="info" plain>返回功能主页</el-button>
        </div>
        <div v-if="page==='config'" class="center-panel-card">
          <ConfigForm />
          <el-button class="back-btn" @click="page='menu'" type="info" plain>返回首页</el-button>
        </div>
        <div v-if="page==='help'" class="center-panel-card">
          <HelpPanel />
          <el-button class="back-btn" @click="page='menu'" type="info" plain>返回首页</el-button>
        </div>
        <div v-if="page==='qr'">
          <QrCodePanel />
          <el-button class="back-btn" @click="page='home'" type="info" plain>返回功能主页</el-button>
        </div>
        <div v-if="page==='aichat'">
          <AiChatPanel />
          <el-button class="back-btn" @click="page='home'" type="info" plain>返回功能主页</el-button>
        </div>
        <div v-if="page==='roommanager'" class="center-panel-card">
          <RoomManagerPanel />
          <el-button class="back-btn" @click="page='menu'" type="info" plain>返回首页</el-button>
        </div>
      </el-main>
    </el-container>
  </div>

  <div class="global-footer-info">© 2025 开发者：六月 | AI Live Assistant</div>
</template>

<script setup>
import { ref, watch } from 'vue'
import MainMenu from './components/MainMenu.vue'
import HomeGrid from './components/HomeGrid.vue'
import ConfigForm from './components/ConfigForm.vue'
import QrCodePanel from './components/QrCodePanel.vue'
import AiChatPanel from './components/AiChatPanel.vue'
import DanmuPanel from './components/DanmuPanel.vue'
import MainProcessPanel from './components/MainProcessPanel.vue'
import HelpPanel from './components/HelpPanel.vue'
import RoomManagerPanel from './components/RoomManagerPanel.vue'

const page = ref('menu') // menu:主菜单 home:功能主页 config:设置中心 help:帮助 qr:扫码 mainprocess:主程序功能
const showConsole = ref(false)
watch(page, () => { showConsole.value = false })
</script>

<style>
/* 统一滚动区域美化样式 */
.scrollable-area {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #e0c6f7 transparent;
}
.scrollable-area::-webkit-scrollbar {
  width: 6px;
}
.scrollable-area::-webkit-scrollbar-thumb {
  background: #e0c6f7;
  border-radius: 3px;
}
/* 全局响应式断点变量 */
:root {
  --breakpoint-xs: 480px;
  --breakpoint-sm: 768px;
  --breakpoint-md: 992px;
  --breakpoint-lg: 1200px;
  --breakpoint-xl: 1600px;
}
.center-panel-card > * {
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-all;
}
html, body, #app {
  width: 100%;
  min-width: 0;
  overflow-x: hidden !important;
  margin: 0;
  padding: 0;
}
body {
  overflow-x: hidden;
}
/* 隐藏所有滚动条（主界面及全局） */
html::-webkit-scrollbar,
body::-webkit-scrollbar,
#app::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
html {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
body {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
#app {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
/* 主背景美化，渐变更柔和，居中适配移动端 */
.soft-bg {
  min-height: 100vh;
  width: 100%;
  background: linear-gradient(120deg, #f8e1f4 0%, #e0f7fa 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow-x: hidden;
}
/* 浏览器宽度自适应，内容居中填满 */
.soft-container {
  width: 100%;
  min-height: 100vh;
  background: rgba(255,255,255,0.92);
  border-radius: 32px;
  box-shadow: 0 8px 32px 0 rgba(180, 138, 214, 0.18);
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}
/* 设置中心/帮助中心内容卡片 */
.center-panel-card {
  border-radius: 24px;
  box-shadow: none;
  padding: 48px 18px 48px 18px;
  margin: 48px auto 48px auto;
  max-width: 100%;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  overflow-x: hidden;
}
.center-panel-card:not(.no-margin-card) {
  overflow-y: auto !important;
  height: 100%;
  scrollbar-width: thin;
  scrollbar-color: #e0c6f7 transparent;
}
.center-panel-card:not(.no-margin-card)::-webkit-scrollbar {
  width: 6px;
}
.center-panel-card:not(.no-margin-card)::-webkit-scrollbar-thumb {
  background: #e0c6f7;
  border-radius: 3px;
}
/* 按钮美化，圆角、阴影、主色调 */
.back-btn {
  margin-top: 18px;
  margin-left: 0;
  max-width: 360px;
  width: 90%;
  min-width: 120px;
  border-radius: 18px !important;
  box-shadow: 0 2px 8px #e0c6f7;
  font-size: 1.08rem;
  font-weight: 500;
  background: linear-gradient(90deg, #f8e1f4 0%, #e0f7fa 100%);
  color: #7c5fa3;
  transition: box-shadow 0.2s, background 0.2s;
  display: block;
  margin-right: auto;
  margin-left: auto;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}
.back-btn:hover {
  box-shadow: 0 4px 16px #b48ad6;
  background: linear-gradient(90deg, #e0f7fa 0%, #f8e1f4 100%);
  color: #b48ad6;
}
/* 卡片美化，圆角、阴影、主色调 */
.grid-card {
  border-radius: 24px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 4px 18px #e0c6f7;
  background: #fff6fa;
  border: none;
}
/* 图标美化 */
.grid-img {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px #e0c6f7;
  background: #fff6fa;
}
/* 标题美化 */
.grid-title {
  font-size: 1.18rem;
  font-weight: bold;
  color: #b48ad6;
  text-align: center;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
@media (max-width: 600px) {
  .soft-container {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    margin: 0;
    box-sizing: border-box;
  }
  .soft-bg {
    padding: 0;
    width: 100%;
    min-width: 0;
  }
}
/* 仅主页、主程序、弹幕管理内容区无边距无圆角 */
.no-margin-card {
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  border: none !important;
  background: transparent !important;
}
/* 全局开发者信息右下角 */
.global-footer-info {
  position: fixed;
  right: 32px;
  bottom: 18px;
  color: #a080c0;
  font-size: 1.02rem;
  letter-spacing: 1px;
  opacity: 0.85;
  z-index: 9999;
  user-select: none;
  transition: all 0.3s ease;
  pointer-events: none;
}
.global-footer-info:hover {
  opacity: 1;
  color: #8a6db4;
}
</style>